{include file="header"}
<div style="padding: 20px;" class="layui-form">
<button class="layui-btn layui-btn-danger" data-url="{:url('set/logindelss')}" lay-submit lay-filter="alldelete">删除选中</button>
<table class="layui-table" >
  <colgroup>
    <col width="150">
    <col width="200">
    <col>
  </colgroup>
  <thead >
    <tr>
    	<th width="40px" align="center"><input type="checkbox" name="checkAll" lay-filter="checkAll" title="全选"></th>
      <th>ID</th>
      <th>IP</th>
      <th>用户名</th>
      <th>状态</th>
      <th>密码</th>
      <th>登录时间</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
{volist name=":fun_s('user_admin_log',array(),'id desc','20,false',0)" id="vo"}
    <tr>
    <td align="center" ><input type="checkbox" name="ids[{$vo.id}]" lay-filter="checkOne" value="{$vo.id}" title="选择"></td>
      <td>{$vo.id}</td>
      <td>{$vo.ip}</td>
      <td>{$vo.name}</td>
      <td>{if condition="$vo['open'] eq '1'"}正常{else /}<font color="#ff5722">密码错误</font>{/if}</td>
      <td>{if condition="$vo['open'] eq '1'"}******{else /}{$vo.password}{/if}</td>
      <td>{$vo.time|timeinfo}</td>
      <td> <a  member-name="确定要删除这条记录吗?" url="{:url("set/delete")}?id={$vo.id}&m=user_admin_log" lay-submit lay-filter="delete"  class="layui-btn layui-btn-danger layui-btn-sm"> <i class="layui-icon">&#xe640;</i>删除</a></td>
    </tr>
{/volist}
  </tbody>
</table>
<div class="pages">
{:fun_s('user_admin_log',array(),'id desc','20,false',0)->render()}
</div>
<script>
    layui.use(['layer','jquery','form', 'laydate'], function() {
        var form = layui.form,
            laydate = layui.laydate,
            $form = $('form'),
            jq = layui.jquery;
        form.on('select()', function(data) {
            $form.submit();
        });

        laydate.render({
            elem: '#startdate' //指定元素
                ,
            done: function(value, date) {
                $form.submit();
            }
        });
        laydate.render({
            elem: '#enddate' //指定元素
                ,
            done: function(value, date) {
                $form.submit();
            }
        });
 
  
  form.on('checkbox(checkAll)', function(data){
    if(data.elem.checked){
      jq("input[lay-filter='checkOne']").prop('checked',true);
    }else{
      jq("input[lay-filter='checkOne']").prop('checked',false);
    }
    form.render('checkbox');
  });  

  form.on('checkbox(checkOne)', function(data){
    var is_check = true;
    if(data.elem.checked){
      jq("input[lay-filter='checkOne']").each(function(){
        if(!jq(this).prop('checked')){ is_check = false; }
      });
      if(is_check){
        jq("input[lay-filter='checkAll']").prop('checked',true);
      }
    }else{
      jq("input[lay-filter='checkAll']").prop('checked',false);
    } 
    form.render('checkbox');
  });

  form.on('submit(alldelete)', function(data){
    var is_check = false;
    jq("input[lay-filter='checkOne']").each(function(){
      if(jq(this).prop('checked')){ is_check = true; }
    });
    if(!is_check){
      layer.msg('请选择数据', {icon: 2,anim: 6,time: 1000});
      return false;
    }
    var url= jq(this).data('url');
   
    layer.confirm('确定批量删除数据吗?', function(index){
      loading = layer.load(2, {
        shade: [0.2,'#000']
      });
      var param = data.field;
    
      jq.post(url,param,function(data){
        if(data.code == 200){
          layer.close(loading);
          layer.msg(data.msg, {icon: 1, time: 1000}, function(){
            location.reload();
          });
        }else{
          layer.close(loading);
          layer.msg(data.msg, {icon: 2,anim: 6, time: 1000});
        }
      });
    });
    return false;
  });
  }); 
</script>
</div>  
{include file="footer"}